// miniprogram/pages/position/position.js
var QQMapWX = require('../../qqmap-wx-jssdk');
var qqmapsdk;
Page({
  data: {
    latitude: 0,//地图初次加载时的纬度坐标
    longitude: 0, //地图初次加载时的经度坐标
    name: "" //选择的位置名称
  },
  onLoad: function () {
    // 实例化API核心类
    qqmapsdk = new QQMapWX({
      key: 'F22BZ-X25RK-TZ6JD-A5IAT-HQT7K-QTFSU'
    });
 
    this.moveToLocation();
  },
  //移动选点
  moveToLocation: function () {
    var that = this;
    wx.chooseLocation({
      success: function (res) {
        console.log(res);
        // address:"广东省广州市天河区天府路1号"
        // errMsg:"chooseLocation:ok"
        // latitude:23.12463
        // longitude:113.36199
        // name:"广州市天河区人民政府"
        /**确定地点并返回*/
        // submit_location: function () {
        getApp().data.activity_lat = res.latitude;
        getApp().data.activity_lng = res.longitude;
        getApp().data.activity_location = res.name;
        wx.navigateBack({
          delta: 1
        });
        console.log(getApp().data.activity_location);
        // }
        //选择地点之后返回到原来页面
        // wx.navigateTo({
        //   url: "/pages/new/new?address=" + res.name
        // });
      },
      fail: function (err) {
        console.log(err)
      }
    });
  }
});